<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>数据表格</title>
		<link rel="stylesheet" href="../../component/pear/css/pear.css" />
	</head>
	<body class="pear-container">

		<div class="layui-card">
			<div class="layui-card-body">
				<form class="layui-form" action="">
					<div class="layui-form-item">

						<div class="layui-inline">
							<label class="layui-form-label">地点</label>
							<div class="layui-input-inline">
								<input type="text" name="address" placeholder="地点" autocomplete="off" class="layui-input">
							</div>
						</div>
		 

						<div class="layui-inline">
							<label class="layui-form-label">状态</label>
							<div class="layui-input-inline">
								<select name="status"  lay-search>
									<option value="1">待确认</option>
									<option value="2">已接单</option>
									<option value="3">已完成</option>
									<option value="4">已取消</option>
									<option value="5">已拒绝</option>
									<option value="">全部</option>
								</select>
							</div>
						</div>

						<div class="layui-inline">
							<div class="layui-input-inline">
								<button class="layui-btn" lay-submit="" lay-filter="user-query">
									<i class="layui-icon">&#xe615;</i>
								</button>
							</div>
						</div>
					</div>
				</form>
			</div>
		</div>

		<div class="layui-card">
			<div class="layui-card-body">
				<table id="user-table" lay-filter="user-table"></table>
			</div>
		</div>


<div id="cou-edit" style="display: none" class="layui-form" lay-filter="cou-edit">
	<div class="layui-card-body">

		<form class="layui-form" action="" onsubmit="return false">
			<input name="id" hidden>
		    <input name="num" hidden>
		
			<div class="layui-form-item">
				<label class="layui-form-label">上课地点</label>
				<div class="layui-input-block">
					<input type="text" name="address" required  lay-verify="required" placeholder="请输入上课地点" autocomplete="off" class="layui-input">
				</div>
			</div>
 
			<div class="layui-form-item">
				<label class="layui-form-label">上课时间</label>
				<div class="layui-input-block">
					<input type="text" name="time" id="date1" required  lay-verify="required" placeholder="请输入课程时间" autocomplete="off" class="layui-input">
				</div>
			</div>
 
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn" lay-submit lay-filter="save">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
	</div>
</div>
 
	<script type="text/html" id="user-type">
		{{#if (d.subjectType == 1) { }}
		<span>语文</span>
		{{# }else if(d.subjectType == 2){ }}
		<span>英语</span>
		{{# }else if(d.subjectType == 3){ }}
		<span>数学</span>
		{{# }else if(d.subjectType == 4){ }}
		<span>物理</span>
		{{# }else if(d.subjectType == 5){ }}
		<span>化学</span>
		{{# }else if(d.subjectType == 6){ }}
		<span>生物</span>
		{{# }else if(d.subjectType == 7){ }}
		<span>历史</span>
		{{# }else if(d.subjectType == 8){ }}
		<span>政治</span>
		{{# }else if(d.subjectType == 9){ }}
		<span>地理</span>
		{{# } }}
	</script>


	<script type="text/html" id="order-type">
		{{#if (d.status == 1) { }}
		<span>待确认</span>
		{{# }else if(d.status == 2){ }}
		<span>已接单</span>
		{{# }else if(d.status == 3){ }}
		<span>已结束</span>
		{{# }else if(d.status == 4){ }}
		<span>已取消</span>
		{{# }else if(d.status == 5){ }}
		<span>已拒绝</span>
		{{# } }}
	</script>
	
	<script type="text/html" id="user-createTime">
		{{layui.util.toDateString(d.createTime, 'yyyy-MM-dd')}}
	</script>

		<script src="../../component/layui/layui.js"></script>
		<script src="../../component/pear/pear.js"></script>
		<script src="../../api/baseApi.js"></script>
		<script src="../../api/subjectApi.js"></script>
		<script src="../../api/orderApi.js"></script>
		<script src="../../component/js/core.util.js"></script>
	
		
		<script>
			layui.use(['table', 'form', 'jquery', 'drawer', 'dropdown','laydate'], function() {
				let table = layui.table;
				let form = layui.form;
				let $ = layui.jquery;
				let drawer = layui.drawer;
				let dropdown = layui.dropdown;
				let laydate = layui.laydate;

				laydate.render({
					elem: '#date1',
					type: 'datetime'
				});
		
				let cols = [
					[{
							type: 'checkbox'
						},
						{
							title: '编号',
							field: 'id',
							align: 'center',
							width: 100
						},
						{
							title: '课程标题',
							field: 'subjectTitle',
							align: 'center'
						},
						{
							title: '上课时间',
							field: 'time',
							align: 'center'
						},
						{
							title: '上课地点',
							field: 'address',
							align: 'center',
							width: 80
						},
						{
							title: '课程类型',
							field: 'subjectType',
							align: 'center',
							templet: '#user-type'
						},
						 {
						 	title: '订单状态',
						 	field: 'status',
						 	align: 'center',
						 	templet: '#order-type'
						 },
						 {
						 	title: '拒绝原因',
						 	field: 'rejectMsg',
						 	align: 'center',
						 },
						{
							title: '创建时间',
							field: 'createTime',
							align: 'center',
							templet: '#user-createTime'
						} 
					]
				]

				table.render({
					request: {
						pageName: 'pageNum' , //页码的参数名称，默认：page
						limitName: 'pageSize' //每页数据量的参数名，默认：limit
					},
					elem: '#user-table',
					url: getTeaOrderList,
					contentType: 'application/json',
					method: 'POST',
					page: true,
					cols: cols,
					skin: 'line',
					limits: [10, 20, 30, 40],
					limit: 10,
					toolbar: '#user-toolbar',
					defaultToolbar: [{
						layEvent: 'refresh',
						icon: 'layui-icon-refresh',
					}, 'filter', 'print', 'exports'],
					parseData: function(res) { //res 即为原始返回的数据
						return {
							"code": res.code, //解析接口状态
							"msg": res.message, //解析提示文本
							"count": res.data.total, //解析数据长度
							"data": res.data.records //解析数据列表
						};
					},
				});

 

				form.on('submit(user-query)', function(data) {
					
					const userId = coreUtil.getLocalDataUserId()
					data.field.stuId=userId			
					table.reload('user-table', {
						where: data.field
					})
					return false;
				});

				form.on('switch(user-enable)', function(obj) {
					layer.tips(this.value + ' ' + this.name + '：' + obj.elem.checked, obj.othis);
				});
 
				window.refresh = function(param) {
					table.reload('user-table');
				}
			})
            
		</script>
	</body>
</html>
